Skip to content

fix: stabilize NonBalancingIntegrationSpec to avoid port-reuse flakiness#651

Merged
He-Pin merged 1 commit intoapache:mainfrom
He-Pin:port/4-fix-nonbalancing-spec
Mar 8, 2026
Merged

fix: stabilize NonBalancingIntegrationSpec to avoid port-reuse flakiness#651
He-Pin merged 1 commit intoapache:mainfrom
He-Pin:port/4-fix-nonbalancing-spec

Conversation

@He-Pin
Copy link
Member

@He-Pin He-Pin commented Mar 8, 2026

Motivation

NonBalancingIntegrationSpec was intermittently failing in CI. After calling server1.terminate(), the OS did not always fully release the port before the test tried to restart a server on the same port. Additionally, a Netty-backend-specific isInstanceOf workaround masked the real failure and degraded test quality by marking the test as pending instead of asserting correctly.

Modification

  • Added Thread.sleep(250) after server1.terminate(5.seconds).futureValue to give the OS time to complete the unbind before restarting the server on the same port
  • Replaced Await.ready(replies, 15.seconds) + isInstanceOf[NonBalancingIntegrationSpecNetty] workaround with a clean Future.sequence(...).futureValue(timeout(15.seconds)) and an unconditional direct assertion

Result

The test is more stable across all backends (both Netty and Pekko HTTP) without special-casing per implementation, and the assertion is more meaningful.

References

Port upstream akka/akka-grpc@93c78cd4.

Add a 250ms sleep after server termination to allow unbind to fully
complete before restarting on the same port. Also simplify the second
connection wait to use futureValue with explicit timeout, removing
the Netty-specific flakiness workaround.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@He-Pin He-Pin marked this pull request as ready for review March 8, 2026 11:33
@pjfanning
Copy link
Member

akka/akka-grpc#1742 is Apache licensed now - see #642

Copy link
Member

@pjfanning pjfanning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@He-Pin He-Pin merged commit 407bbce into apache:main Mar 8, 2026
15 checks passed
@He-Pin He-Pin deleted the port/4-fix-nonbalancing-spec branch March 8, 2026 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants